<?php  session_start();
/**
* @package		Parents@School
* @copyright	                Copyright (C) 2008 Kristof Beckers. All rights reserved.
* @Version		2.0
* @license		GNU/GPL, see LICENSE.php
**/
include ("../../include/config.php");
require_once ("../../include/db.php");
include ("../../include/header.php");
?>
<head>
<link rel="stylesheet" href="../../css/template_css.css" type="text/css"/> 
<script type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}
//-->
</script>
</head>

<body>
<div align="center">
  <p><img src="<?php echo "../$logo" ; ?>" /><br />
    <br />
    <a href="../index.php"/><img src="<?php echo "../$home" ; ?>" border="0"/></a><br>
    <br>
    </p>
  <form name="form1" method="post" action="">
    <p>
      <?php

if(isset($_SESSION['myusername'])){
	if ($_SESSION['admin'] == "$adminid") {
	
// De geselecteerde datum ophalen
$datumselect = $_GET['datum'];

// Datum selecteren om de reservaties te bekijken.

$sqlhrs = "SELECT DISTINCT date from $tbdate";
$resulthrs = mysql_query($sqlhrs);


// Hier gaan we de leerkracht selecteren waarvan we de reservaties willen bekijken.

$sqllk = "SELECT DISTINCT Leerkrachtnaam,LeerkrachtID FROM $tbvak ORDER BY Leerkrachtnaam ASC";
		$resultlk = mysql_query($sqllk);
$datum123 = $_GET['datum'];
?>
    </p>
    <p><a href="../pdf/pdfstijn.php?datum=<?php echo "$datum123" ; ?>">Maak een pdf van alle inschrijvingen (per leerkracht)</a>. </p>
    <p>&nbsp;</p>
    <p> Selecteer de leerkracht waarvan je de reservaties online wil bekijken : <br>
      <br>
      Selecteer een datum: <br />
	  <?php 
	  while ($rowhrs = mysql_fetch_array($resulthrs)){
		$date = $rowhrs['date'];
	 ?>
	<a href="?datum=<?php echo "$date" ; ?>"><?php echo "$date" ; ?></a><br />
	<?php } ?>
	<br />
	<br />

      </label>
      <select name="lk" class="inputbox" onChange="MM_jumpMenu('self',this,1)">
	  <option ></option>
	  <option value="?lk=Iedereen&amp;datum=<?php echo "$datumselect" ;?>">Iedereen</option>
	  	<?php 
		while ($rowlk = mysql_fetch_array($resultlk)){
		$lk = $rowlk['Leerkrachtnaam'];
		$lkid = $rowlk['LeerkrachtID']; ?>
        <option value="?lk=<?php echo "$lkid" ;?>&amp;datum=<?php echo "$datumselect" ;?>"><?php echo "$lk" ;?></option> <?php } ?>
      </select>
      <br/>
	  <br/>
    </p>
    <table class='moduletable-latest1'>
      <tr>
        <td width="150"><strong>Leerling</strong></td>
		<td ><strong>Leerkracht </strong></td>
        <td ><strong>Uur</strong></td>
        <td ><strong>Vak</strong></td>
        <td ><strong>Lokaal</strong></td>
        <td><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong></td>
      </tr>
    </table>
    <?php

// Als er een leerkracht geselecteerd is, de reserveringen van deze LK weergeven.

$lkidselected = $_GET['lk'];

if ($datumselect !== ""){

if ( $lkidselected !== 'Iedereen') {



$sqlres="SELECT * FROM $tbres WHERE LeerkrachtID='$lkidselected' AND datum='$datumselect'";
			$resultres=mysql_query($sqlres);
				
				
				while ($rowres =mysql_fetch_array($resultres)) {
						$id = $rowres['ReservatieID'];
						$llnres = $rowres['Gebruikersnaam'];
						$lkres = $rowres['Leerkrachtnaam'];
						$klasres = $rowres['Klas'];
						$uurres = $rowres['Uur'];
						$vakres = $rowres['Vak'];
						$lokres = $rowres['Lokaal'];
		?>
								
 <table class='moduletable-latest1'>
      <tr>
        <td width="150"><?php echo "$llnres" ; ?></td>
		<td ><?php echo "$lkres" ; ?> </td>
        <td ><?php echo "$uurres" ; ?></td>
        <td ><?php echo "$vakres" ; ?></td>
        <td ><?php echo "$lokres" ; ?></td>
        <td><a href="delete_reservation.php?id=<?php echo "$id" ; ?>"/>Verwijder afspraak</a></td>
      </tr>
    </table>	
<?php 
	}
}
//Als iedereen geselecteerd is, de reserveringen van iedereen weergeven.

if ( $lkidselected == 'Iedereen') {

$sql="SELECT * FROM $tbres WHERE datum='$datumselect'";
			$result=mysql_query($sql);
				
				
				while ($row =mysql_fetch_array($result)) {
						$id1 = $row['ReservatieID'];
						$lln = $row['Gebruikersnaam'];
						$lk1 = $row['Leerkrachtnaam'];
						$klas = $row['Klas'];
						$uur = $row['Uur'];
						$vak = $row['Vak'];
						$lok = $row['Lokaal'];
		?>
								
 <table class='moduletable-latest1'>
      <tr>
        <td width="150"><?php echo "$lln" ; ?></td>
		<td ><?php echo "$lk1" ; ?> </td>
        <td ><?php echo "$uur" ; ?></td>
        <td ><?php echo "$vak" ; ?></td>
        <td ><?php echo "$lok" ; ?></td>
        <td><a href="delete_reservation.php?id=<?php echo "$id1" ; ?>"/>Verwijder afspraak</a></td>
      </tr>
    </table> 

 </form>
	
<?php 

}}}
else
{
echo "Gelieve eerst een datum te selecteren";
}
}}
else{
header("location:index.php");
}


?>
   
  
</div>
</body>